package com.yjt.sousou;

import android.text.TextUtils;

import com.yjt.sousou.user.LoginTag;
import com.yjt.sousou.utils.HDPreference;

/**
 * 作者：83734
 * 时间：2018/11/26
 * 描述：
 */
public class Api {

    private Api(){}

    private static class Holder{
        static final Api instance = new Api();
    }

    public static Api get(){
        return Holder.instance;
    }

//    private static final String BASE_URL = "http://mytest.51bxt.com/api/?";
    private String BASE_URL = "";
    private String MODULE_USER = BASE_URL + "module=User&opt=";
    private String MODULE_JILU = BASE_URL + "module=Jilu&opt=";
    private String MODULE_MY_DB = BASE_URL + "module=Mydb&opt=";
    private String MODULE_FILE = BASE_URL + "module=Files&opt=";
    private String MODULE_STATISTIC = BASE_URL + "module=Statistics&opt=";
    private String MODULE_PEIJIAN = BASE_URL + "module=Peijian&opt=";
    private String MODULE_KUFNAG = BASE_URL + "module=Kufang&opt=";
    private String MODULE_EXPENT = BASE_URL + "module=expend&opt=";

    private  String LOGIN = MODULE_USER +  "login";
    private  String REPAIRS = MODULE_USER +  "lists";//维修员列表
    private  String CHANGE_STATE = MODULE_USER +  "update_state";//切换工作状态
    private  String CHANGE_PASSWORD = MODULE_USER +  "update_password";//修改密码
    private  String EXIT = MODULE_USER +  "exit";//退出登录

    private  String ORDER_LIST = MODULE_JILU +  "lists";//工单列表
    private  String CREATE_NEW_ORDER = MODULE_JILU +  "add";//新建工单
    private  String ORDER_DETAIL = MODULE_JILU +  "con";//工单详情
    private  String ORDER_RECEIVE = MODULE_JILU +  "jiedan";//接单
    private  String ORDER_DISPATCH = MODULE_JILU +  "paigong";//派工
    private  String ORDER_PRESS = MODULE_JILU +  "weixiuguocheng";//维修过程
    private  String ORDER_RETURN = MODULE_JILU +  "tuidan";//退单
    private  String ORDER_EVALUATE = MODULE_JILU +  "pingjia";//评价
    private  String ORDER_DELETE = MODULE_JILU +  "del";//删除

    private  String LOCATION = MODULE_MY_DB +  "weizhi_lists";//位置
    private  String DEVICE = MODULE_MY_DB +  "shebei_lists";//设备
    private  String FAULT_TYPE = MODULE_MY_DB +  "gzlx_lists";//故障类型
    private  String DEPARTMENT = MODULE_MY_DB +  "bumn_lists";//部门
    private  String GROUP = MODULE_MY_DB +  "fenzu_lists";//分组
    private  String CLOOECTION_LIST = MODULE_MY_DB +  "collection_lists";//特殊工单

    private  String FILE = MODULE_FILE +  "save_img";//上传文件

    private  String RANKING = MODULE_STATISTIC +  "user_works";//积分排名

    public void setBASE_URL(String url) {
        BASE_URL = "http://"+url+"/api/?";
        HDPreference.setUserId(LoginTag.BASE_URL.name(),BASE_URL);
        MODULE_USER = BASE_URL + "module=User&opt=";
        MODULE_JILU = BASE_URL + "module=Jilu&opt=";
        MODULE_MY_DB = BASE_URL + "module=Mydb&opt=";
        MODULE_FILE = BASE_URL + "module=Files&opt=";
        MODULE_STATISTIC = BASE_URL + "module=Statistics&opt=";
        MODULE_PEIJIAN = BASE_URL + "module=Peijian&opt=";
        MODULE_KUFNAG = BASE_URL + "module=Kufang&opt=";
        MODULE_EXPENT = BASE_URL + "module=expend&opt=";
    }

    private void setModule(){
        BASE_URL = HDPreference.getUserId(LoginTag.BASE_URL.name());
        MODULE_USER = BASE_URL + "module=User&opt=";
        MODULE_JILU = BASE_URL + "module=Jilu&opt=";
        MODULE_MY_DB = BASE_URL + "module=Mydb&opt=";
        MODULE_FILE = BASE_URL + "module=Files&opt=";
        MODULE_STATISTIC = BASE_URL + "module=Statistics&opt=";
        MODULE_PEIJIAN = BASE_URL + "module=Peijian&opt=";
        MODULE_KUFNAG = BASE_URL + "module=Kufang&opt=";
        MODULE_EXPENT = BASE_URL + "module=expend&opt=";
    }

    public String getLoginNew() {
        return "http://reg.51sousou.com/index.php?c=port&m=actionGet_Android_v2_Port&module=Weixin&opt=login_app";
    }

    public String getLogin() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_USER +  "login";
    }


    public String getSaveParts() {
        if(TextUtils.isEmpty(MODULE_EXPENT)) setModule();
        return MODULE_EXPENT +  "save";
    }
    public String getKindList() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_PEIJIAN +  "type_list";
    }
    public String getRoomList() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_KUFNAG +  "list";
    }
    /**
     * 获取配件列表url
     * @return
     */
    public String getPartsList() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_PEIJIAN +  "list";
    }
    public String getRepairs() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_USER +  "lists";//维修员列表;
    }

    public String getChangeState() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_USER +  "update_state";//切换工作状态;
    }

    public String getChangePassword() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_USER +  "update_password";//修改密码;
    }

    public String getExit() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_USER +  "exit";//退出登录;
    }

    public String getOrderList() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_JILU +  "lists";//工单列表;
    }

    public String getCreateNewOrder() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_JILU +  "add";//新建工单;
    }

    public String getOrderDetail() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_JILU +  "con";//工单详情;
    }

    public String getOrderReceive() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_JILU +  "jiedan";//接单;
    }

    public String getOrderDispatch() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_JILU +  "paigong";//派工;
    }

    public String getOrderPress() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_JILU +  "weixiuguocheng";//维修过程;
    }
    public String getProcessGroup() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_JILU +  "weixiuguocheng_fenzu";//获取维修过程中获取可操作的分组
    }

    public String getOrderReturn() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_JILU +  "tuidan";//退单;
    }

    public String getOrderEvaluate() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_JILU +  "pingjia";//评价;
    }

    public String getOrderDelete() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_JILU +  "del";//删除;
    }

    public String getLocation() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_MY_DB +  "weizhi_lists";//位置;
    }

    public String getDevice() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_MY_DB +  "shebei_lists";//设备;
    }

    public String getFaultType() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_MY_DB +  "gzlx_lists";//故障类型;
    }

    public String getDepartment() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_MY_DB +  "bumn_lists";//部门;
    }

    public String getGroup() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_MY_DB +  "fenzu_lists";//分组;
    }

    public String getClooectionList() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_MY_DB +  "collection_lists";//特殊工单;
    }

    public String getFile() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_FILE +  "save_img";//上传文件;
    }

    public String getRanking() {
        if(TextUtils.isEmpty(BASE_URL)) setModule();
        return MODULE_STATISTIC +  "user_works";//积分排名;
    }
}
